﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace SystemDiagramNew
{
	public class PipeDeailLineFilter : ISelectionFilter
	{
		public PipeDeailLineFilter(Document document)
		{
			this.doc = document;
		}

		public bool AllowElement(Element elem)
		{
			bool result = false;
			if (typeof(DetailLine) != elem.GetType())
			{
				return result;
			}
			DetailLine detailLine = elem as DetailLine;
			if (detailLine != null && this.doc != null)
			{
				ElementId modelId = detailLine.GetModelId();
				if (modelId != ElementId.InvalidElementId)
				{
					Pipe pipe = this.doc.GetElement(modelId) as Pipe;
					result = (pipe != null);
				}
			}
			return result;
		}

		public bool AllowReference(Reference reference, XYZ pos)
		{
			return false;
		}

		public Document doc;
	}
}
